package com.alstudio.utils.mission;

import java.util.HashMap;

import com.alstudio.utils.mission.ALMissionHttpManager.MissionInfoCallback;
import com.alstudio.utils.mission.parser.TaskMainParser;

public class MissionParserConfig {

	private HashMap<String, MissionPackageCallback> map = new HashMap<String, MissionPackageCallback>();

	public MissionParserConfig() {
		registerIQParseMethod();
	}

	public void registerIQParseMethod() {
		map.put(MissionNameSpace.NS_TASK_MAIN, new TaskMainParser());
//		map.put(MissionNameSpace.NS_LEVEL_LIST, new LevelTaskListParser());
//		map.put(MissionNameSpace.NS_LEVEL_INFO, new TaskLevelInfoParser());
//		map.put(MissionNameSpace.NS_DAILY_LIST, new DailyTaskListParser());
//		map.put(MissionNameSpace.NS_DAILY_LIST_INFO,
//				new DailyTaskDetailParser());
	}

	public synchronized void getXmlParser(String stream, String ns,
			MissionInfoCallback listener) {
		if (map.get(ns) != null) {
			MissionPackageCallback callback = map.get(ns);
			try {
				callback.parseXmlPackage(stream, listener);
			} catch (Exception e) {
				// TODO Auto-generated catch block
				e.printStackTrace();
			}
		}
	}

}
